<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
      .myclass{
        background-color: skyblue;
      }
      button{
        border: 0
      }
    </style>
  </head>
  <body>
    <div id="root">
    <button @click="img1" :class="bgc1">图片1</button>
    <button @click="img2" :class="bgc2">图片2</button>
    <button @click="img3" :class="bgc3">图片3</button>
    <br>
    <img :src="imgtype" alt="">
     </div>
  </body>
  <script>
    Vue.config.productionTip = false;
    new Vue({
      el: "#root",
      data() {
        return {
          bgc1:'',
          bgc2:'',
          bgc3:'',
          imgtype:'./1.png'
        }
      },
      methods: {
       img1(){
        this.bgc1="myclass"
        this.bgc2=''
        this.bgc3=''
        this.imgtype="./1.png"
       },
       img2(){
        this.bgc1=""
        this.bgc2='myclass'
        this.bgc3=''
        this.imgtype="./2.png"
       },
       img3(){
         this.bgc1=""
        this.bgc2=''
        this.bgc3='myclass'
        this.imgtype="./3.png"
       }
      },
    });
  </script>
</html>
